package situ.autoweter.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import situ.autoweter.entity.RdRead;
import situ.autoweter.entity.SyEmp;
import situ.autoweter.service.RdTaskService;
import situ.autoweter.entity.RdTask;
import java.util.*;
/**
 * RdTask的路由接口服务
 * 
 * @author 胡文
 *
 */
@Controller
public class RdTaskController {

	/** RdTaskService服务 */
	@Autowired
	private RdTaskService rdTaskService;

	@RequestMapping("/rd_task_set")
	public  String hh(){
		return "rd_task_set.html";
	}
	//侯慧林写的多表联查
	@GetMapping("/rd_task")
	public String queryallHll(Map map){
		List<Map> list =rdTaskService.queryallHll();
		map.put("items", list);
		return "page/rd_task";
	}
	//侯慧林写的单查
	@RequestMapping("/rd_task_set/{id}")
	public String findOneHll(@PathVariable(name="id") int id,Map map) {
		Map list=  rdTaskService.findOneHll(id);
		map.put("emplist", rdTaskService.queryallEmp());

		map.put("items",list);
		return "page/rd_task_set";
	}





	/**
	 * 查询所有RdTask数据的方法
	 * @param value
	 * @return
	 */
	@RequestMapping(value ="" ,produces = {"application/json;charset=UTF-8"})
	public String find(RdTask value,Map map) {
		 List<RdTask> list= rdTaskService.find(value);
		 list.forEach(s-> System.out.println(s));
         map.put("items",list);
         return "页面名称自己改";
	}
	
	/**
	 * 通过id查询RdTask数据的方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "queryRdTaskById/{id}", produces = {"application/json;charset=UTF-8"})
	public String findOne(@PathVariable(name="id") Object id,Map map) {
        RdTask obj=  rdTaskService.findOne(id);
        map.put("RdTask",obj);
        return "页面名称自己改";
	}
	
	/**
	 * 插入RdTask属性不为空的数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "saveRdTask", produces = {"application/json;charset=UTF-8"})
	public String save(RdTask value) {
		  rdTaskService.saveNotNull(value);
        return "redirect:/queryRdTask";
	}
	
	/**
	 * 更新RdTask属性不为空的数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "updateRdTask", produces = {"application/json;charset=UTF-8"})
	public String update(RdTask value) {
		  rdTaskService.updateNotNullById(value);
          return "redirect:/queryRdTask";
	}
	
	/**
	 * 通过id删除RdTask数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "delRdTaskById/{id}", produces = {"application/json;charset=UTF-8"})
	public String delete(@PathVariable(name="id") Object id) {
		  rdTaskService.deleteById(id);
          return "redirect:/queryRdTask";
	}
}
